package com.example.vehiclemanagesystem.service.Impl;

import com.example.vehiclemanagesystem.dao.CarDao;
import com.example.vehiclemanagesystem.entity.Car;
import com.example.vehiclemanagesystem.service.CarService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;

@Service
public class CarServiceImpl implements CarService {
    @Autowired
    private  CarDao carDao;
    @Override
    public Car selectCarByCarID(Integer c_id) {
        return carDao.selectCarByCarID(c_id);
    }

    @Override
    public void addNewDCar(Car car) {
        if(car.getTime() == null){
            car.setTime(new Date());
        }
        carDao.addNewDCar(car);
    }

    @Override
    public void updateCar(Car car) {
        if(car.getTime() == null){
            car.setTime(new Date());
        }
        carDao.updateCar(car);
    }

    @Override
    public void deleteCar(Car car) {
        carDao.deleteCar(car);
    }

    @Override
    public List<Car> selectCarAll(String c_id) {
        return carDao.selectCarAll(c_id);
    }
    @Override
    public List<Car> selectCarById(String c_id) {
        return carDao.selectCarById(c_id);
    }


}
